package middleware

import (
	"github.com/gin-contrib/cors"
	"github.com/gin-gonic/gin"
	"time"
)

func CorsMiddleWare() gin.HandlerFunc {
	return cors.New(cors.Config{
		//AllowOrigins: []string{"http://localhost:5173"},
		AllowOrigins:     []string{"*"},
		AllowMethods:     []string{"GET", "POST", "PUT", "PATCH", "DELETE"},
		AllowHeaders:     []string{"Authorization", "Content-Type", "Origin", "X-Requested-With"},
		AllowCredentials: true,
		ExposeHeaders:    []string{"Content-Type", "Content-Length", "Access-Control-Allow-Origin", "Authorization"},
		MaxAge:           time.Hour,
	})
}
